#include "metrics/utility/Strings.hpp"

namespace metrics
{
    Strings::Strings(/* args */)
    {
    }

    Strings::~Strings()
    {
    }

    std::vector<std::string> Strings::split(const std::string &str, const std::string &delim)
    {
        std::vector<std::string> substr_list;
        if (str.empty() || delim.empty())
        {
            substr_list.push_back(str);
            return substr_list;
        }
        std::string::size_type start = 0;
        while (true)
        {
            std::string::size_type pos = str.find(delim, start);
            if (pos == start)
            {
                substr_list.push_back(std::string());
                start += delim.length();
                continue;
            }
            else if (pos == std::string::npos)
            {
                substr_list.push_back(str.substr(start));
                break;
            }
            else
            {
                substr_list.push_back(str.substr(start, pos - start));
                start = pos + delim.length();
            }
        }

        return substr_list;
    }
} // namespace metrics